/*
 * @Description: 租户配置管理 - 接口
 * @Author: DSY
 * @Date: 2022-12-30 16:00:28
 * @LastEditors: DHL
 * @LastEditTime: 2023-01-05 14:48:19
 */

import { $get, $post, $put, $exportExcel } from '/@/utils/http'
import { ContentTypeEnum } from '/@/constant/http'
import {
  TenantConfigModel,
  TenantConfigParams,
  TenantConfigPageParams,
  TenantConfigPageResultModel,
  TenantConfigResultModel
} from './model/tenantConfigModel'

/**
 * 分页查询
 */
export const apiTenantConfigSearch = (searchParams: TenantConfigPageParams) =>
  $get<TenantConfigPageResultModel>({
    url: '/system/tenantConfig/search',
    params: searchParams
  })

/**
 * 根据ID获取详情
 */
export const apiTenantConfigGetById = (id: string) =>
  $get<TenantConfigResultModel>({
    url: '/system/tenantConfig/getById',
    params: { id: id }
  })

/**
 * 保存信息
 */
export const apiTenantConfigSave = (saveParams: TenantConfigModel) =>
  $post<TenantConfigResultModel>({
    url: '/system/tenantConfig/save',
    contentType: ContentTypeEnum.json,
    params: saveParams
  })

/**
 * 更新信息
 */
export const apiTenantConfigUpdateById = (updateParams: TenantConfigModel) =>
  $put<TenantConfigResultModel>({
    url: '/system/tenantConfig/updateById',
    contentType: ContentTypeEnum.json,
    params: updateParams
  })

/**
 * 批量删除信息
 */
export const apiTenantConfigBatchDeleteByIds = (ids: string) =>
  $post<TenantConfigResultModel>({
    url: '/system/tenantConfig/batchDeleteByIds',
    params: { ids: ids }
  })

/**
 * 批量逻辑删除
 */
export const apiTenantConfigLogicBatchDeleteByIds = (ids: string) =>
  $post<TenantConfigResultModel>({
    url: '/system/tenantConfig/logicBatchDeleteByIds',
    params: { ids: ids }
  })

/**
 * 导出
 */
export const apiTenantConfigExport = (searchParams: TenantConfigParams, fileName: string) =>
  $exportExcel<TenantConfigResultModel>(
    {
      url: '/system/tenantConfig/exportExcel',
      params: searchParams
    },
    fileName
  )

/**
 * 根据类型获取详情
 * @param configType
 * @returns
 */
export const apiTenantConfigGetByType = (configType: string) =>
  $get<TenantConfigResultModel>({
    url: '/system/tenantConfig/getByType',
    params: { configType: configType }
  })
